/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            housekeepingTypeInfo: {
                housekeepingTypes: [],
                total: 0,
                records: 1,
                moreCondition: false,
                hktId: '',
                conditions: {
                    hktName: '',
                    isShow: '',
                    shopId: '9999',
                    typeCd: '2002'
                }
            }
        },
        _initMethod: function () {
            $that._listHousekeepingTypes(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {

            vc.on('housekeepingType', 'listHousekeepingType', function (_param) {
                $that._listHousekeepingTypes(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listHousekeepingTypes(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listHousekeepingTypes: function (_page, _rows) {

                $that.housekeepingTypeInfo.conditions.page = _page;
                $that.housekeepingTypeInfo.conditions.row = _rows;
                let param = {
                    params: $that.housekeepingTypeInfo.conditions
                };
                //发送get请求
                vc.http.apiGet('/housekeepingType.queryHousekeepingType',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        $that.housekeepingTypeInfo.total = _json.total;
                        $that.housekeepingTypeInfo.records = _json.records;
                        $that.housekeepingTypeInfo.housekeepingTypes = _json.data;
                        vc.emit('pagination', 'init', {
                            total: $that.housekeepingTypeInfo.records,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _openAddAMenuModal: function () {
                vc.emit('addAMenu', 'openAddAMenuModal', {});
            },
            _openAddAShopMenuModal:function(){
                vc.emit('addAShopMenu', 'openAddAShopMenuModal', {});
            },
			_openAddAShopTypeMenuModal:function(){
			    vc.emit('addAShopTypeMenu', 'openAddAShopTypeMenuModal', {});
			},
            _openAddAGoodsMenuModal:function(){
                vc.emit('addAGoodsMenu', 'openAddAGoodsMenuModal', {});
            },
            _openAddAServTypeMenuModal:function(){
                vc.emit('addAServTypeMenu', 'openAddAServTypeMenuModal', {});
            },
            _openAddAServMenuModal:function(){
                vc.emit('addAServMenu', 'openAddAServMenuModal', {});
            },
            _openEditHousekeepingTypeModel: function (_housekeepingType) {
                vc.emit('editMallMenu', 'openEditMallMenuModal', _housekeepingType);
            },
            _openDeleteHousekeepingTypeModel: function (_housekeepingType) {
                vc.emit('deleteMallMenu', 'openDeleteMallMenuModal', _housekeepingType);
            },
            _queryHousekeepingTypeMethod: function () {
                $that._listHousekeepingTypes(DEFAULT_PAGE, DEFAULT_ROWS);

            },
            _moreCondition: function () {
                if ($that.housekeepingTypeInfo.moreCondition) {
                    $that.housekeepingTypeInfo.moreCondition = false;
                } else {
                    $that.housekeepingTypeInfo.moreCondition = true;
                }
            }
        }
    });
})(window.vc);
